# -*- codeing = utf-8 -*-
# @Time : 2021/2/23 14:30
# @Atuthor: 朱朱
# @File: 069函数调用函数.py
# @Software: PyCharm

def test1():
    print('1开始了.')
    print('1结束了.')

def test2():
    print('2开始了..')
    test1() # 执行到调用函数,先把调用函数执行完,再执行后面的
    print('2结束了..')

test2()

# 定义函数求[n,m)之间所有整数之和
def sum(n,m):
    x = 0
    for i in range(n,m+1):
        x+=i
    print(x)
    return x

sum(1,100)

# 求一个n的阶乘
def factorial(n):
    x =1
    for i in range(1,n+1):
        x = x*i
    # print(x) # 注销,方便下面调用此函数
    return x
factorial(5)

# 计算m阶乘的和  m=6 ==> 1!+2!+3!+4!+5!+6!
def fac_sum(m):
    x = 0
    for i in range(1,m+1):
        x = x+factorial(i)
    print(x)
    return x

fac_sum(5)